<template>
  <div class="JNPF-common-layout">
    <Detail v-show="detailVisible" ref="Detail" @close="detailVisible = false" />
  </div>
</template>

<script>
import Detail from './detail'
import { getConfigData } from '@/api/onlineDev/visualDev'
export default {
  name: 'logAgent',
  components: { Detail},
  data() {
    return {
      modelId: '',
      id:'',
      detailVisible: false,
      config: {}
    }
  },
  mounted() {
    debugger
  },
  created() {
    this.modelId = this.$route.query.modelId
    this.id = this.$route.query.id;
    debugger
    if (!this.modelId||!this.id) return
    this.getConfigData()
  },
  beforeDestroy() {
   
  },
  methods: {
    getConfigData() {
      getConfigData(this.modelId).then(res => {
        if (res.code !== 200) {
          this.$store.dispatch('tagsView/delView', this.$route)
          this.$router.replace('/404?p_layout=appmain')
        }
        if (!res.data) return
        this.config = res.data
        if (!this.config.columnData || !this.config.formData) return
        this.columnData = JSON.parse(this.config.columnData)
        this.formData = JSON.parse(this.config.formData)
        this.goDetail()
      }).catch(() => { })
    },
    goDetail() {
      this.detailVisible = true
      this.$nextTick(() => {
        this.$refs.Detail.init(this.formData, this.modelId, this.id, this.columnData.useFormPermission)
      })
    },
  }
}
</script>
